<?php

namespace App\Enums;

/**
 * 盘点单状态
 */
enum InventoryOrderStatus: int
{
    case WAIT   = 0;
    case ING    = 10;
    case FINISH = 20;

    /**
     * 获取名称
     * @return string
     */
    public function label(): string
    {
        return match ($this) {
            self::WAIT      => "待盘点",
            self::ING       => "盘点中",
            self::FINISH    => "盘点完成",
        };
    }

    /**
     * 根据值获取名称
     * @param $val
     * @return string
     */
    static function labelBy($val){
        $obj = self::tryFrom((int)$val);
        return $obj ? $obj->label() : '';
    }

}
